import curses

class graph:
    
    def __init__(element="LOAD",nodes):
        self.element = element
        self.nodes = nodes
        self.std = curses.initscr()
        curses.noecho()
        curses.cbreak()
        self.height, self.width = self.std.getmaxyx()

    def setelement(element):
        self.element = element

    
    def __labelaxis(self):
        pos = self.height/2 -2
        for x in self.element.split():
            self.std.move(pos,0)
            self.std.addstr(x)
            pos +=2
        self.std.move(self.height-1,0)
        self.std.addstr("Node #")
        
    def __caliberate(self):
        space = (self.height-2)/4
        for n in range(5):
            self.std.move(self.height -2 - space*n,2)
            self.std.addstr(str(0.25 * n))


    def __drawaxis(self):
        rem = (self.height-2)%4
        self.std.vline(0 + rem, 7,'|', self.height -1 - rem)
        self.std.hline(self.height -2,7,'-',self.width -7)    
    

        
    def draw():
        self.__drawaxis()
        self.__labelaxis()
        self.__caliberate()
    
        std.refresh()
        values = self.nodes.getNodes()
        
        for n in self.nodes.getNodes():
            measure = float(values[n])
            for y in range(int(measure * (self.height -2))):
                self.std.move(b[0] - y,9)
                self.std.standout()
                self.std.addch(' ')
    

        
        
            
        
        
    